<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Custom - Getting started - Spectre.css CSS Framework</title>
    <meta charset="utf-8">
    <meta name="robots" content="index, follow">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <meta name="description" content="Spectre.css CSS Framework is a lightweight, responsive and modern CSS framework for faster and extensible development. Spectre provides basic styles for typography and elements, flexbox based responsive layout system, pure CSS components and utilities with best practice coding and consistent design language.">
    <meta name="author" content="Yan Zhu">
    <meta property="og:url" content="https://picturepan2.github.io/spectre/getting-started/custom.html">
    <meta property="og:title" content="Custom - Getting started - Spectre.css CSS Framework">
    <meta property="og:description" content="Spectre.css CSS Framework is a lightweight, responsive and modern CSS framework for faster and extensible development. Spectre provides basic styles for typography and elements, flexbox based responsive layout system, pure CSS components and utilities with best practice coding and consistent design language.">
    <meta name="twitter:card" content="summary">
    <meta name="twitter:site" content="@spectrecss">
    <meta name="twitter:creator" content="@picturepan2">
    <link rel="shortcut icon" href="../img/favicons/favicon.ico">
    <link rel="icon" href="../img/favicons/favicon.png">
    <link rel="stylesheet" href="../dist/spectre.min.css">
    <link rel="stylesheet" href="../dist/spectre-icons.min.css">
    <link rel="stylesheet" href="../dist/spectre-exp.min.css">
    <link rel="stylesheet" href="../dist/docs.min.css">
    <link rel="canonical" href="https://picturepan2.github.io/spectre/getting-started/custom.html">
  </head>
  <body>
    <div class="docs-container off-canvas off-canvas-sidebar-show">
      <div class="docs-navbar"><a class="off-canvas-toggle btn btn-link btn-action" href="#sidebar"><i class="icon icon-menu"></i></a>
        <div class="btns d-flex">
          <input class="docs-search form-input" type="text" placeholder="Search Docs"><a class="btn ml-1" href="https://www.paypal.me/picturepan2" target="_blank">PayPal</a><a class="btn btn-primary ml-1" href="https://github.com/picturepan2/spectre" target="_blank">GitHub</a>
        </div>
      </div>
      <div class="docs-sidebar off-canvas-sidebar" id="sidebar">
        <div class="docs-brand"><a class="docs-logo" href="../index.html"><img src="../img/spectre-logo.svg" alt="Spectre.css CSS Framework">
            <h2>SPECTRE</h2><small class="label label-secondary text-bold">DOCS</small></a>
        </div>
        <div class="docs-nav">
          <div class="accordion-container">
            <div class="accordion">
              <input id="accordion-getting-started" type="checkbox" name="docs-accordion-checkbox" hidden="" checked="checked"/>
              <label class="accordion-header c-hand" for="accordion-getting-started">Getting started</label>
              <div class="accordion-body">
                <ul class="menu menu-nav">
                  <li class="menu-item"><a href="../getting-started/installation.html">Installation</a>
                  </li>
                  <li class="menu-item"><a href="../getting-started/custom.html">Custom version</a>
                  </li>
                  <li class="menu-item"><a href="../getting-started/browsers.html">Browser support</a>
                  </li>
                  <li class="menu-item"><a href="../getting-started/whatsnew.html">What's new</a>
                  </li>
                </ul>
              </div>
            </div>
            <div class="accordion">
              <input id="accordion-elements" type="checkbox" name="docs-accordion-checkbox" hidden=""/>
              <label class="accordion-header c-hand" for="accordion-elements">Elements</label>
              <div class="accordion-body">
                <ul class="menu menu-nav">
                  <li class="menu-item"><a href="../elements/typography.html">Typography</a>
                  </li>
                  <li class="menu-item"><a href="../elements/tables.html">Tables</a>
                  </li>
                  <li class="menu-item"><a href="../elements/buttons.html">Buttons</a>
                  </li>
                  <li class="menu-item"><a href="../elements/forms.html">Forms</a>
                  </li>
                  <li class="menu-item"><a href="../elements/icons.html">Icons.css</a>
                  </li>
                  <li class="menu-item"><a href="../elements/labels.html">Labels</a>
                  </li>
                  <li class="menu-item"><a href="../elements/code.html">Code</a>
                  </li>
                  <li class="menu-item"><a href="../elements/media.html">Media</a>
                  </li>
                </ul>
              </div>
            </div>
            <div class="accordion">
              <input id="accordion-layout" type="checkbox" name="docs-accordion-checkbox" hidden=""/>
              <label class="accordion-header c-hand" for="accordion-layout">Layout</label>
              <div class="accordion-body">
                <ul class="menu menu-nav">
                  <li class="menu-item"><a href="../layout/grid.html">Flexbox grid</a>
                  </li>
                  <li class="menu-item"><a href="../layout/responsive.html">Responsive</a>
                  </li>
                  <li class="menu-item"><a href="../layout/hero.html">Hero</a>
                  </li>
                  <li class="menu-item"><a href="../layout/navbar.html">Navbar</a>
                  </li>
                </ul>
              </div>
            </div>
            <div class="accordion">
              <input id="accordion-components" type="checkbox" name="docs-accordion-checkbox" hidden=""/>
              <label class="accordion-header c-hand" for="accordion-components">Components</label>
              <div class="accordion-body">
                <ul class="menu menu-nav">
                  <li class="menu-item"><a href="../components/accordions.html">Accordions</a>
                  </li>
                  <li class="menu-item"><a href="../components/avatars.html">Avatars</a>
                  </li>
                  <li class="menu-item"><a href="../components/badges.html">Badges</a>
                  </li>
                  <li class="menu-item"><a href="../components/bars.html">Bars</a>
                  </li>
                  <li class="menu-item"><a href="../components/breadcrumbs.html">Breadcrumbs</a>
                  </li>
                  <li class="menu-item"><a href="../components/cards.html">Cards</a>
                  </li>
                  <li class="menu-item"><a href="../components/chips.html">Chips</a>
                  </li>
                  <li class="menu-item"><a href="../components/empty.html">Empty states</a>
                  </li>
                  <li class="menu-item"><a href="../components/menu.html">Menu</a>
                  </li>
                  <li class="menu-item"><a href="../components/modals.html">Modals</a>
                  </li>
                  <li class="menu-item"><a href="../components/nav.html">Nav</a>
                  </li>
                  <li class="menu-item"><a href="../components/pagination.html">Pagination</a>
                  </li>
                  <li class="menu-item"><a href="../components/panels.html">Panels</a>
                  </li>
                  <li class="menu-item"><a href="../components/popovers.html">Popovers</a>
                  </li>
                  <li class="menu-item"><a href="../components/steps.html">Steps</a>
                  </li>
                  <li class="menu-item"><a href="../components/tabs.html">Tabs</a>
                  </li>
                  <li class="menu-item"><a href="../components/tiles.html">Tiles</a>
                  </li>
                  <li class="menu-item"><a href="../components/toasts.html">Toasts</a>
                  </li>
                  <li class="menu-item"><a href="../components/tooltips.html">Tooltips</a>
                  </li>
                </ul>
              </div>
            </div>
            <div class="accordion">
              <input id="accordion-utilities" type="checkbox" name="docs-accordion-checkbox" hidden=""/>
              <label class="accordion-header c-hand" for="accordion-utilities">Utilities</label>
              <div class="accordion-body">
                <ul class="menu menu-nav">
                  <li class="menu-item"><a href="../utilities/colors.html">Colors</a>
                  </li>
                  <li class="menu-item"><a href="../utilities/cursors.html">Cursors</a>
                  </li>
                  <li class="menu-item"><a href="../utilities/display.html">Display</a>
                  </li>
                  <li class="menu-item"><a href="../utilities/divider.html">Divider</a>
                  </li>
                  <li class="menu-item"><a href="../utilities/loading.html">Loading</a>
                  </li>
                  <li class="menu-item"><a href="../utilities/position.html">Position</a>
                  </li>
                  <li class="menu-item"><a href="../utilities/shapes.html">Shapes</a>
                  </li>
                  <li class="menu-item"><a href="../utilities/text.html">Text</a>
                  </li>
                </ul>
              </div>
            </div>
            <div class="accordion">
              <input id="accordion-experimentals" type="checkbox" name="docs-accordion-checkbox" hidden=""/>
              <label class="accordion-header c-hand" for="accordion-experimentals">Experimentals</label>
              <div class="accordion-body">
                <ul class="menu menu-nav">
                  <li class="menu-item"><a href="../experimentals/viewer-360.html">360-Degree Viewer</a>
                  </li>
                  <li class="menu-item"><a href="../experimentals/autocomplete.html">Autocomplete</a>
                  </li>
                  <li class="menu-item"><a href="../experimentals/calendars.html">Calendars</a>
                  </li>
                  <li class="menu-item"><a href="../experimentals/carousels.html">Carousels</a>
                  </li>
                  <li class="menu-item"><a href="../experimentals/comparison.html">Comparison sliders</a>
                  </li>
                  <li class="menu-item"><a href="../experimentals/filters.html">Filters</a>
                  </li>
                  <li class="menu-item"><a href="../experimentals/meters.html">Meters</a>
                  </li>
                  <li class="menu-item"><a href="../experimentals/off-canvas.html">Off-canvas</a>
                  </li>
                  <li class="menu-item"><a href="../experimentals/parallax.html">Parallax</a>
                  </li>
                  <li class="menu-item"><a href="../experimentals/progress.html">Progress</a>
                  </li>
                  <li class="menu-item"><a href="../experimentals/sliders.html">Sliders</a>
                  </li>
                  <li class="menu-item"><a href="../experimentals/timelines.html">Timelines</a>
                  </li>
                </ul>
              </div>
            </div>
          </div>
        </div>
      </div><a class="off-canvas-overlay" href="#close"></a>
      <div class="off-canvas-content">
        <div class="docs-content" id="content">
          <div class="container" id="custom">
            <h3 class="s-title">Custom version<a class="anchor" href="#custom" aria-hidden="true">#</a></h3>
            <div class="docs-ad">
              <div class="hide-md text-center">
                <script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
                <!-- GitHub-lg--><ins class="adsbygoogle mx-auto" style="display:inline-block;width:728px;height:90px" data-ad-client="ca-pub-2225124559530218" data-ad-slot="9894180784"></ins>
                <script>(adsbygoogle = window.adsbygoogle || []).push({});</script>
              </div>
              <div class="show-md text-center">
                <!-- GitHub-sm--><ins class="adsbygoogle" style="display:inline-block;width:300px;height:250px" data-ad-client="ca-pub-2225124559530218" data-ad-slot="9278881734"></ins>
                <script>(adsbygoogle = window.adsbygoogle || []).push({});</script>
              </div>
            </div>
            <p>You can customize your version of Spectre.css by editing Sass files in <code>/src</code> directory or removing unneeded components from <code>.scss</code> source files.</p>
            <p><a class="btn btn-primary" href="https://github.com/picturepan2/spectre/" target="_blank">Sass Source Code</a></p>
            <p>If you are looking for Less version of Spectre.css, please switch to <code>Less</code> branch.</p>
            <p><a class="btn" href="https://github.com/picturepan2/spectre/tree/less" target="_blank">Less Branch</a></p>
            <h4 class="s-subtitle" id="compiling">Compiling CSS<a class="anchor" href="#compiling" aria-hidden="true">#</a></h4>
            <p>Spectre uses <a href="http://gulpjs.com/" target="_blank">Gulp</a> for compiling CSS. Firstly you need to <a href="https://www.npmjs.com/get-npm" target="_blank">install NPM</a>, which is used to manage Gulp and other dependencies.</p>
            <p>Then, you can build the CSS file from the command line:</p>
            <ol>
              <li>Navigate to the root directory of Spectre.</li>
              <li>Run <code>npm install</code>. NPM will install all dev dependencies as listed in package.json.</li>
              <li>When completed, run <code>gulp build</code> task to compile Sass to CSS and minify files.</li>
              <li>You can find compiled CSS files in <code>/dist</code> directory.</li>
            </ol>
            <p>All available Gulp tasks:</p>
            <ul>
              <li><code>gulp build</code> - compile Sass to CSS and minify files (default)</li>
              <li><code>gulp docs</code> - compile Docs related files</li>
              <li><code>gulp watch</code> - watch file changes and re-compile CSS files</li>
            </ul>
            <h4 class="s-subtitle" id="importing">Importing Sass<a class="anchor" href="#importing" aria-hidden="true">#</a></h4>
            <p>It is recommended to customize Spectre by importing Sass source files to your projects. In this way, you can keep Spectre up to date without conflicts, since Spectre code and your custom code are separate.</p>
            <ul>
              <li>First, create your own project and install Spectre via <a href="#installation">NPM or other package managers</a>.</li>
              <li>Then create your <code>project-name.scss</code> file in the root folder. You can use <code>project-name.scss</code> to define your variables.</li>
              <li>Compile the Sass file to CSS to get the custom version of Spectre.</li>
            </ul>
            <pre class="code" data-lang="Sass"><code><span class="hljs-comment">// Example of project-name.scss</span>
<span class="hljs-comment">// Define variables to override default ones</span>
<span class="hljs-variable">$primary-color</span>: <span class="hljs-number">#2e5bec</span>;
<span class="hljs-variable">$dark-color</span>: <span class="hljs-number">#3e396b</span>;

<span class="hljs-comment">// Import full Spectre source code</span>
<span class="hljs-keyword">@import</span> <span class="hljs-string">"node_modules/spectre.css/src/spectre"</span>;
</code></pre>
            <p>Alternatively, you can create custom <code>_variables.scss</code> and import it to <code>project-name.scss</code>.</p>
            <pre class="code" data-lang="Sass"><code><span class="hljs-comment">// Example of project-name.scss</span>
<span class="hljs-keyword">@import</span> <span class="hljs-string">"variables"</span>;

<span class="hljs-comment">// Import only the needed components</span>
<span class="hljs-keyword">@import</span> <span class="hljs-string">"node_modules/spectre.css/src/buttons"</span>;
<span class="hljs-keyword">@import</span> <span class="hljs-string">"node_modules/spectre.css/src/forms"</span>;
</code></pre>
            <h4 class="s-subtitle" id="folders">Folder structure<a class="anchor" href="#folders" aria-hidden="true">#</a></h4>
            <pre class="code"><code>spectre/
├── <span class="hljs-built_in">dist</span>/                           <span class="hljs-comment">// Build folder</span>
│   ├── spectre-<span class="hljs-built_in">exp</span>.css
│   ├── spectre-<span class="hljs-built_in">exp</span>.<span class="hljs-built_in">min</span>.css
│   ├── spectre-icons.css
│   ├── spectre-icons.<span class="hljs-built_in">min</span>.css
│   ├── spectre.css
│   └── spectre.<span class="hljs-built_in">min</span>.css
│
├── docs/
│   ├── <span class="hljs-built_in">dist</span>/                       <span class="hljs-comment">// Pre-built CSS folder</span>
│   │   ├── spectre-<span class="hljs-built_in">exp</span>.css
│   │   ├── spectre-<span class="hljs-built_in">exp</span>.<span class="hljs-built_in">min</span>.css
│   │   ├── spectre-icons.css
│   │   ├── spectre-icons.<span class="hljs-built_in">min</span>.css
│   │   ├── spectre.css
│   │   └── spectre.<span class="hljs-built_in">min</span>.css
|   ├── css/                        <span class="hljs-comment">// Docs CSS files</span>
│   │   └── docs.css
|   ├── src/
│   │   ├── scss                    <span class="hljs-comment">// Docs Sass files</span>
│   │   │   └── docs.scss
│   │   ├── index.pug               <span class="hljs-comment">// Docs Pug files</span>
│   │   └── ...
│   ├── examples/                   <span class="hljs-comment">// Example tempalte</span>
│   │   └── starter.html
│   ├── ../
│   ├── index.html
│   └── ...
│
├── src/                            <span class="hljs-comment">// Source Sass files</span>
│   ├── spectre.scss
│   ├── spectre-icons.scss
│   ├── spectre-<span class="hljs-built_in">exp</span>.scss
│   ├── _mixins.scss
│   ├── _variables.scss
│   └── ...
│
├── gulpfile.js
├── <span class="hljs-keyword">package</span>.json
└── ...
</code></pre>
            <h4 class="s-subtitle" id="variables">Variables<a class="anchor" href="#variables" aria-hidden="true">#</a></h4>
            <p>Spectre.css is designed with consistent design language. You can use your own variables to create your new or match existing design. All variables in <code>_variables.scss</code> include <code>!default</code> flag. You can redefine the variables to override the values.</p>
            <h4 class="s-subtitle" id="variables-colors">Variables - Colors<a class="anchor" href="#variables-colors" aria-hidden="true">#</a></h4>
            <div class="columns">
              <div class="column col-2 col-md-6">
                <div class="docs-color" style="background:#5755d9;color:#fff;">
                  <div class="color-title">#5755d9</div>
                  <div class="color-subtitle">Primary</div>
                </div>
              </div>
              <div class="column col-2 col-md-6">
                <div class="docs-color" style="background:#f1f1fc;color:#5755d9;">
                  <div class="color-title">#f1f1fc</div>
                  <div class="color-subtitle">Secondary</div>
                </div>
              </div>
            </div>
            <div class="columns">
              <div class="column col-2 col-md-6">
                <div class="docs-color" style="background:#32b643;color:#fff;">
                  <div class="color-title">#32b643</div>
                  <div class="color-subtitle">Success</div>
                </div>
              </div>
              <div class="column col-2 col-md-6">
                <div class="docs-color" style="background:#ffb700;color:#fff;">
                  <div class="color-title">#ffb700</div>
                  <div class="color-subtitle">Warning</div>
                </div>
              </div>
              <div class="column col-2 col-md-6">
                <div class="docs-color" style="background:#e85600;color:#fff;">
                  <div class="color-title">#e85600</div>
                  <div class="color-subtitle">Error</div>
                </div>
              </div>
            </div>
            <div class="columns">
              <div class="column col-2 col-md-6">
                <div class="docs-color" style="background:#303742;color:#fff;">
                  <div class="color-title">#303742</div>
                  <div class="color-subtitle">Dark</div>
                </div>
              </div>
              <div class="column col-2 col-md-6">
                <div class="docs-color" style="background:#66758c;color:#fff;">
                  <div class="color-title">#66758c</div>
                  <div class="color-subtitle">Gray dark</div>
                </div>
              </div>
              <div class="column col-2 col-md-6">
                <div class="docs-color" style="background:#bcc3ce;color:#fff;">
                  <div class="color-title">#bcc3ce</div>
                  <div class="color-subtitle">Gray</div>
                </div>
              </div>
              <div class="column col-2 col-md-6">
                <div class="docs-color" style="background:#f7f8f9;color:#66758c;">
                  <div class="color-title">#f7f8f9</div>
                  <div class="color-subtitle">Gray light</div>
                </div>
              </div>
              <div class="column col-2 col-md-6">
                <div class="docs-color" style="background:#fff;color:#bcc3ce;">
                  <div class="color-title">#fff</div>
                  <div class="color-subtitle">Light</div>
                </div>
              </div>
            </div>
            <h4 class="s-subtitle" id="variables-buttons">Variables - Button mixins<a class="anchor" href="#variables-buttons" aria-hidden="true">#</a></h4>
            <p>There are 2 button variant mixins in <code>_mixins.scss</code> to generate different color variants.</p>
            <ul>
              <li>@mixin button-variant(<code>$color</code>: $primary-color);</li>
              <li>@mixin button-outline-variant(<code>$color</code>: $primary-color);</li>
            </ul>
            <pre class="code" data-lang="Sass"><code>&lt;!-- filled <span class="hljs-selector-tag">button</span> with the success <span class="hljs-attribute">color</span> --&gt;
<span class="hljs-selector-class">.btn-success</span> {
  <span class="hljs-keyword">@include</span> button-variant(<span class="hljs-variable">$success-color</span>);
}

&lt;!-- outlined <span class="hljs-selector-tag">button</span> with the success <span class="hljs-attribute">color</span> --&gt;
<span class="hljs-selector-class">.btn-outline-success</span> {
  <span class="hljs-keyword">@include</span> button-outline-variant(<span class="hljs-variable">$success-color</span>);
}
</code></pre>
            <h4 class="s-subtitle" id="variables-sizes">Variables - Sizes<a class="anchor" href="#variables-sizes" aria-hidden="true">#</a></h4>
            <p>The default REM (root em) size in Spectre.css is <code>20px</code>.</p>
            <p>Please note in the Chinese/Japanese/Korean version, Chrome uses 12px as default minimum font size. That is why Spectre sets rem default html font size to <code>20px</code>, which is relatively easy to calculate.</p>
            <p>Spectre uses <code>4px</code> as the unit size. Sizes of components are based on the unit size.</p>
            <h4 class="s-subtitle" id="variables-custom-prefix">Variables - Custom prefix<a class="anchor" href="#variables-custom-prefix" aria-hidden="true">#</a></h4>
            <p>There is also a way to add custom prefix to all CSS classes. You can use <a href="https://www.npmjs.com/package/gulp-css-prefix" target="_blank">gulp-css-prefix</a> plugin and add a new Gulp task to enable it.</p>
            <pre class="code" data-lang="Bash"><code>npm install gulp-css-prefix
</code></pre>
            <p>To add <code>spectre-</code> to all classes, you can add the Gulp task to <code>gulpfile.js</code> file.</p>
            <pre class="code"><code><span class="hljs-keyword">var</span> cssPrefix = <span class="hljs-built_in">require</span>(<span class="hljs-string">'gulp-css-prefix'</span>);

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">prefix</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">return</span> gulp
    .src(<span class="hljs-string">'./dist/*.css'</span>)
    .pipe(cssPrefix(<span class="hljs-string">'spectre-'</span>))
    .pipe(gulp.dest(<span class="hljs-string">'./dist'</span>));
}

exports.prefix = prefix;
</code></pre>
            <p>After you compile your version of Spectre in the /dist, run <code>gulp prefix</code> in the directory of Spectre.</p>
          </div>
          <div class="docs-footer container grid-lg" id="copyright">
            <p><a href="https://github.com/picturepan2/spectre" target="_blank">GitHub</a> · <a href="https://twitter.com/spectrecss" target="_blank">Twitter</a> · <a href="https://www.paypal.me/picturepan2" target="_blank">PayPal Donate</a> · <a href="https://www.patreon.com/spectrecss" target="_blank">Patreon Sponsor</a> · Version <span class="version"></span></p>
            <p>Designed and built with <span class="text-error">&hearts;</span> by <a href="https://twitter.com/picturepan2" target="_blank">Yan Zhu</a>. Licensed under the <a href="https://github.com/picturepan2/spectre/blob/master/LICENSE" target="_blank">MIT License</a>.</p>
          </div>
        </div>
      </div>
    </div>
    <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js"></script>
    <script>
      docsearch({ 
      apiKey: 'bede06373c5a1fa3c1bbe8401e24c653', 
      indexName: 'picturepan2_spectre', 
      inputSelector: '.docs-search', 
      debug: true
      }); 
    </script>
    <script>
      (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
            (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
          m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
      })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
      
      ga('create', 'UA-2702768-8', 'auto');
      ga('send', 'pageview');
    </script>
  </body>
</html>